<!doctype html>



  


<html class="theme-next mist use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>






<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.1" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="Hexo,建博客,Hexo教程," />








  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.1.1" />






<meta name="description" content="一、账号和软件准备1、码云地址，注册一个账号2、Hexo地址，这里有说明文档和主题3、Node.js安装: 参考 4、Git安装: 参考二、搭建环境新建项目在码云上新建与自己个性地址同名的项目aolomode，打开page服务，就可以以http://aolomode.oschina.io 进行访问了。 Hexo安装12## 建议挂代理，不然很难安装成功npm install -g hexo-cl">
<meta name="keywords" content="Hexo,建博客,Hexo教程">
<meta property="og:type" content="article">
<meta property="og:title" content="Hexo建设自己的博客">
<meta property="og:url" content="http://yoursite.com/2017/04/23/Hexo_boke/index.html">
<meta property="og:site_name" content="杂七杂八">
<meta property="og:description" content="一、账号和软件准备1、码云地址，注册一个账号2、Hexo地址，这里有说明文档和主题3、Node.js安装: 参考 4、Git安装: 参考二、搭建环境新建项目在码云上新建与自己个性地址同名的项目aolomode，打开page服务，就可以以http://aolomode.oschina.io 进行访问了。 Hexo安装12## 建议挂代理，不然很难安装成功npm install -g hexo-cl">
<meta property="og:updated_time" content="2017-06-30T12:43:11.354Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Hexo建设自己的博客">
<meta name="twitter:description" content="一、账号和软件准备1、码云地址，注册一个账号2、Hexo地址，这里有说明文档和主题3、Node.js安装: 参考 4、Git安装: 参考二、搭建环境新建项目在码云上新建与自己个性地址同名的项目aolomode，打开page服务，就可以以http://aolomode.oschina.io 进行访问了。 Hexo安装12## 建议挂代理，不然很难安装成功npm install -g hexo-cl">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Mist',
    sidebar: {"position":"left","display":"post","offset":12,"offset_float":0,"b2t":false,"scrollpercent":false},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://yoursite.com/2017/04/23/Hexo_boke/"/>





  <title>Hexo建设自己的博客 | 杂七杂八</title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  











  <div style="display: none;">
    <script src="//s95.cnzz.com/z_stat.php?id=1261868868&web_id=1261868868" language="JavaScript"></script>
  </div>






  
  
    
  

  <div class="container sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">杂七杂八</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">AoloMode 的博客</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      

      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="popup-trigger">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br />
            
            搜索
          </a>
        </li>
      
    </ul>
  

  
    <div class="site-search">
      
  <div class="popup search-popup local-search-popup">
  <div class="local-search-header clearfix">
    <span class="search-icon">
      <i class="fa fa-search"></i>
    </span>
    <span class="popup-btn-close">
      <i class="fa fa-times-circle"></i>
    </span>
    <div class="local-search-input-wrapper">
      <input autocomplete="off"
             placeholder="搜索..." spellcheck="false"
             type="text" id="local-search-input">
    </div>
  </div>
  <div id="local-search-result"></div>
</div>



    </div>
  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2017/04/23/Hexo_boke/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="韦超">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="杂七杂八">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">Hexo建设自己的博客</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-04-23T10:08:50+08:00">
                2017-04-23
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Hexo/" itemprop="url" rel="index">
                    <span itemprop="name">Hexo</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          
            <span class="post-meta-divider">|</span>
            <span class="page-pv"><i class="fa fa-file-o"></i>
            <span class="busuanzi-value" id="busuanzi_value_page_pv" ></span>
            </span>
          

          

          

        </div>
      </header>
    

    <div class="post-body" itemprop="articleBody">

      
      

      
        <hr>
<h1 id="一、账号和软件准备"><a href="#一、账号和软件准备" class="headerlink" title="一、账号和软件准备"></a>一、账号和软件准备</h1><p>1、<a href="https://git.oschina.net/" target="_blank" rel="external">码云地址</a>，注册一个账号<br>2、<a href="https://hexo.io/zh-cn/" target="_blank" rel="external">Hexo地址</a>，这里有说明文档和主题<br>3、Node.js安装: <a href="http://www.runoob.com/nodejs/nodejs-install-setup.html" target="_blank" rel="external">参考</a></p>
<h2 id="4、Git安装-参考"><a href="#4、Git安装-参考" class="headerlink" title="4、Git安装: 参考"></a>4、Git安装: <a href="http://www.runoob.com/git/git-install-setup.html" target="_blank" rel="external">参考</a></h2><h1 id="二、搭建环境"><a href="#二、搭建环境" class="headerlink" title="二、搭建环境"></a>二、搭建环境</h1><h2 id="新建项目"><a href="#新建项目" class="headerlink" title="新建项目"></a>新建项目</h2><p>在码云上新建与自己个性地址同名的项目aolomode，打开page服务，就可以以<a href="http://aolomode.oschina.io" target="_blank" rel="external">http://aolomode.oschina.io</a> 进行访问了。</p>
<h2 id="Hexo安装"><a href="#Hexo安装" class="headerlink" title="Hexo安装"></a>Hexo安装</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">## 建议挂代理，不然很难安装成功</div><div class="line">npm install -g hexo-cli</div></pre></td></tr></table></figure>
<h2 id="生成文件"><a href="#生成文件" class="headerlink" title="生成文件"></a>生成文件</h2><p>如果有之前已经生成文件的话就不需要进行这个步骤了<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line"># 在桌面上右键 Git Bash Here</div><div class="line">hexo init weichao  ## 会在桌面新建一个 weichao(想用什么名你看着办) 的文件夹，下面的例子我将全部以weichao为例子</div><div class="line">cd weichao</div><div class="line">npm install</div><div class="line">hexo generate ## 简写 hexo g</div></pre></td></tr></table></figure></p>
<h2 id="本地浏览"><a href="#本地浏览" class="headerlink" title="本地浏览"></a>本地浏览</h2><p>每次写完文章 hexo g 生成文件后，想先要在本地运行看看效果的话，可以在weichao这个目录下(cd weichao)执行以下命令:<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">npm install</div><div class="line">hexo server ## 简写 hexo s</div><div class="line">## 然后，在浏览器里输入 http://localhost:4000</div></pre></td></tr></table></figure></p>
<h2 id="部署码云"><a href="#部署码云" class="headerlink" title="部署码云"></a>部署码云</h2><p>这里使用git将项目中public文件夹下的文件管理起来，并推送到码云上。借用一个插件来帮助我们完成，安装 hexo-deployer-git。安装代码如下：<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">npm install hexo-deployer-git --save</div><div class="line">## 如果之前已经生成文件并执行了此命令，那么就不需要再重复此步骤了</div></pre></td></tr></table></figure></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">hexo deploy ## 简写hexo d</div></pre></td></tr></table></figure>
<p>如果使用熟练后，以后每次写完文章，可以在weichao目录下这样输入:<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">hexo clean ## 清楚缓存，这一步不一定每次都要做</div><div class="line">hexo g -d</div></pre></td></tr></table></figure></p>
<p>部署完成后，点击进入地址查看: <a href="http://aolomode.oschina.io" target="_blank" rel="external">点击进入</a></p>
<hr>
<h1 id="三、其它补充"><a href="#三、其它补充" class="headerlink" title="三、其它补充"></a>三、其它补充</h1><h2 id="常用命令总结"><a href="#常用命令总结" class="headerlink" title="常用命令总结"></a>常用命令总结</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">hexo clean # clean 清除缓存文件 (db.json) 和已生成的静态文件 (public)</div></pre></td></tr></table></figure>
<h2 id="配置"><a href="#配置" class="headerlink" title="配置"></a>配置</h2><p>_config.yml文件<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div></pre></td><td class="code"><pre><div class="line"># Site</div><div class="line">title: Hexo ## 站点标题</div><div class="line">subtitle: ## 站点副标题</div><div class="line">description: ## 站点描述</div><div class="line">author: John Doe ## 作者</div><div class="line">language: ## 语言包，需要主题自带才可设置。如Jcaman自带简繁英，设置简体中文填入 zh-CN</div><div class="line">timezone:</div><div class="line">    </div><div class="line">theme: landscape ##当前主题名称</div></pre></td></tr></table></figure></p>
<hr>
<h1 id="四、写文章"><a href="#四、写文章" class="headerlink" title="四、写文章"></a>四、写文章</h1><p>用Markdown写文章， 写完后导出md文件放入Hexo项目的source 目录下的_posts 文件夹中，可以在weichao目录输入:<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">hexo g</div><div class="line">hexo d</div><div class="line">上述可以写成 hexo g -d</div></pre></td></tr></table></figure></p>
<hr>
<h1 id="五、技巧问题汇总"><a href="#五、技巧问题汇总" class="headerlink" title="五、技巧问题汇总"></a>五、技巧问题汇总</h1><blockquote>
<p>部署到OSChina之后，一直没有效果</p>
</blockquote>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line">## 目前不知道原因，重装系统后重新把所有的git，ssh弄了就好了，估计是因为C:\Users\AoloMode\.gitconfig 文件中的：</div><div class="line">[user]</div><div class="line">	name = weichao</div><div class="line">	email = weichao</div><div class="line">## 被我不小心删除有关。</div></pre></td></tr></table></figure>
<blockquote>
<p><a href="http://blog.csdn.net/eangulee/article/details/50461573" target="_blank" rel="external">git http 提交免密码:</a></p>
</blockquote>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div></pre></td><td class="code"><pre><div class="line">## 长期保存密码：</div><div class="line">$ git config --global credential.helper store</div><div class="line">## 可查看电脑 C:\Users\AoloMode\.gitconfig 文件，如果之前配置了名字和email的话，在这里面会看到(我的被我删除了)。</div><div class="line"></div><div class="line">## 设置记住密码（默认15分钟）：</div><div class="line">$ git config --global credential.helper cache</div><div class="line"></div><div class="line">## 自己设置时间，1小时之后失效：</div><div class="line">$ git config credential.helper &apos;cache --timeout=3600&apos;</div></pre></td></tr></table></figure>
<blockquote>
<p>部署到另一个一个码云服务器</p>
</blockquote>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line">## 只需要复制原有的Hexo项目，改一下配置文件即可</div><div class="line">deploy:</div><div class="line">  type: git</div><div class="line">  repo: https://git.oschina.net/aolomode/aolomode.git</div><div class="line">  branch: master</div><div class="line">## 注意：部署的时候需要输入用户名和密码的话，一定是码云的用户名而不是昵称哈</div></pre></td></tr></table></figure>
<blockquote>
<p>导致Markdown标题语法失效的原因</p>
</blockquote>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">## 由于我采用了一下自定义的样式，在&lt;/p&gt;标签后一定要给它一个换行，否则会导致该标签后的一些Markdown标题语法样式失效。</div><div class="line">`&lt;p class=&quot;image-caption&quot;&gt;我配的电脑&lt;/p&gt;`</div></pre></td></tr></table></figure>
<blockquote>
<p>Hexo博客的首页显示的是完整的文章，而文章比较长的时候这无疑会带来诸多不遍，怎么样才能只显示个摘要:</p>
</blockquote>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">这里显示图片和摘要等</div><div class="line">&lt;!--more--&gt;</div><div class="line">这里是全文</div></pre></td></tr></table></figure>
<blockquote>
<p>用Markdown编写的文章，部署到码云后，有些标签语法会失效。</p>
</blockquote>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">原因是有些标签和语法会互相干扰，尽量注意给某些标签换行。例如容易受干扰的标签有引用、分割线等，注意在这些标签的末尾换行，如果你的文章有些地方显示出问题，多半是没有换行导致的标签干扰问题。</div></pre></td></tr></table></figure>
<blockquote>
<p>Hexo之next主题设置首页不显示全文(只显示预览)</p>
</blockquote>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">## 进入hexo博客项目的themes/next目录，打开_config.yml，&quot;auto_excerpt&quot;中更改为:</div><div class="line">auto_excerpt</div><div class="line">enable: true</div><div class="line">length: 150</div></pre></td></tr></table></figure>
<blockquote>
<p>Hexo的NexT主题，怎么取消“文章目录”对标题的自动编号？</p>
</blockquote>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line"># 修改主题配置文件那里的number为false</div><div class="line"># Table Of Contents in the Sidebar</div><div class="line">toc:</div><div class="line">  enable: true</div><div class="line"></div><div class="line">  # Automatically add list number to toc.</div><div class="line">  number: true</div></pre></td></tr></table></figure>
<hr>
<h1 id="六、一些工具和教程地址"><a href="#六、一些工具和教程地址" class="headerlink" title="六、一些工具和教程地址:"></a>六、一些工具和教程地址:</h1><p>1、<a href="http://blog.leanote.com/post/freewalk/Markdown-%E8%AF%AD%E6%B3%95%E6%89%8B%E5%86%8C#title-14" target="_blank" rel="external">语法 - Markdown语法</a><br>2、<a href="https://maxiang.io/" target="_blank" rel="external">工具 - 马克飞象Markdown在线编辑器</a><br>3、<a href="http://www.jianshu.com/p/c2ba9533088a" target="_blank" rel="external">图片 - hexo博客图片问题:</a></p>
<ul>
<li>config.yml文件，修改为post_asset_folder: true</li>
<li>执行 <code>npm install https://github.com/CodeFalling/hexo-asset-image --save</code></li>
<li>source/_posts目录下面会多出一个和文章名字一样的文件夹</li>
<li>把图片文件放到这个目录，在Markdown文件中使用<code>![logo](图片文件夹名/logo.jpg)</code> 就可以插入图片</li>
</ul>
<p>4、<a href="https://hexo.io/themes/" target="_blank" rel="external">主题 - Hexo主题下载和修改:</a></p>
<ul>
<li>解压 然后放到theme文件夹中</li>
<li>配置文件_config.yml，theme : hexo-theme-smackdown-master (注意“：”后面有空格)</li>
<li>然后重新hexo g和hexo d (部署之后输入码云的用户名和密码，一定要注意是你的用户名，不是昵称哈，之前我就搞错了，另外输入密码的时候看不到有输入交互，没问题请输入完成后回车等待即可)</li>
</ul>
<p>5、<a href="http://www.jianshu.com/p/72408c410904" target="_blank" rel="external">Hexo站点中添加文章目录以及归档</a></p>
<p>6、<a href="http://theme-next.iissnan.com/theme-settings.html" target="_blank" rel="external">为主题添加「标签」和「分类」页面</a></p>
<blockquote>
<p><strong>添加标签</strong></p>
</blockquote>
<ol>
<li><p>新建标签页面:</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ hexo new page tags</div></pre></td></tr></table></figure>
</li>
<li><p>编辑站点的source/tags/index.md，添加:</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">title: 标签</div><div class="line">date: 2017-10-20 06:49:50</div><div class="line">type: &quot;tags&quot;</div><div class="line">comments: false # 如果主题有评论功能，那么在标签页面会显示，这句是在标签页面去掉评论功能。</div></pre></td></tr></table></figure>
</li>
<li><p>修改菜单: 编辑主题配置文件_config，添加 tags 到 menu 中:</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">menu:</div><div class="line">  home: /</div><div class="line">  archives: archives</div><div class="line">  tags: tags</div></pre></td></tr></table></figure>
</li>
</ol>
<blockquote>
<p> <strong>添加分类</strong></p>
</blockquote>
<ol>
<li><p>新建分类页面:</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ hexo new page categories</div></pre></td></tr></table></figure>
</li>
<li><p>编辑站点的source/categories/index.md，添加:</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">title: categories</div><div class="line">date: 2015-10-20 06:49:50</div><div class="line">type: &quot;categories&quot;</div><div class="line">comments: false # 如果主题有评论功能，那么在标签页面会显示，这句是在标签页面去掉评论功能。</div></pre></td></tr></table></figure>
</li>
<li><p>修改菜单: 编辑主题配置文件_config， 添加 categories 到 menu 中下:</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">menu:</div><div class="line">  home: /</div><div class="line">  archives: archives</div><div class="line">  categories: categories</div></pre></td></tr></table></figure>
</li>
</ol>
<p>7、<a href="http://www.jianshu.com/p/739bf1305e66" target="_blank" rel="external">使用Hexo搭建博客（四），博客的部件和插件</a><br>8、<a href="https://github.com/iTimeTraveler/hexo-theme-hipaper/blob/master/README.cn.md" target="_blank" rel="external">我使用的 Hipaper 主题配置</a></p>
<ul>
<li>注意: 使用搜索工具之前您必须使用 hexo-generator-json-content 来安装，在Hexo根目录下执行命令如下：<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ npm install -S hexo-generator-json-content</div></pre></td></tr></table></figure>
</li>
</ul>
<p>9、<a href="http://blog.csdn.net/captain_magicer/article/details/49073873" target="_blank" rel="external">Hexo博客主题NexT使用自定义的CSS样式</a><br>10、<a href="http://theme-next.iissnan.com/" target="_blank" rel="external">Next主题官网 - 使用文档</a><br>11、<a href="https://segmentfault.com/q/1010000008494901" target="_blank" rel="external">hexo的NexT主题，怎么取消“文章目录”对标题的自动编号？</a></p>

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/Hexo/" rel="tag"># Hexo</a>
          
            <a href="/tags/建博客/" rel="tag"># 建博客</a>
          
            <a href="/tags/Hexo教程/" rel="tag"># Hexo教程</a>
          
        </div>
      

      
        
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2017/04/28/txf_sqys/" rel="next" title="社区原生化方案（草稿，编辑中，请勿看）">
                <i class="fa fa-chevron-left"></i> 社区原生化方案（草稿，编辑中，请勿看）
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2017/04/23/sheyingketang/" rel="prev" title="摄影课堂笔记 - 第一课">
                摄影课堂笔记 - 第一课 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/avatar.gif"
               alt="韦超" />
          <p class="site-author-name" itemprop="name">韦超</p>
           
              <p class="site-description motion-element" itemprop="description">工作、学习、生活中的点滴！</p>
          
        </div>
        <nav class="site-state motion-element">

          
            <div class="site-state-item site-state-posts">
              <a href="/archives">
                <span class="site-state-item-count">19</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          
            
            
            <div class="site-state-item site-state-categories">
              <a href="/categories/index.html">
                <span class="site-state-item-count">5</span>
                <span class="site-state-item-name">分类</span>
              </a>
            </div>
          

          
            
            
            <div class="site-state-item site-state-tags">
              <a href="/tags/index.html">
                <span class="site-state-item-count">32</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
        </div>

        
        

        
        

        


      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#一、账号和软件准备"><span class="nav-text">一、账号和软件准备</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#4、Git安装-参考"><span class="nav-text">4、Git安装: 参考</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#二、搭建环境"><span class="nav-text">二、搭建环境</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#新建项目"><span class="nav-text">新建项目</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Hexo安装"><span class="nav-text">Hexo安装</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#生成文件"><span class="nav-text">生成文件</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#本地浏览"><span class="nav-text">本地浏览</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#部署码云"><span class="nav-text">部署码云</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#三、其它补充"><span class="nav-text">三、其它补充</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#常用命令总结"><span class="nav-text">常用命令总结</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#配置"><span class="nav-text">配置</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#四、写文章"><span class="nav-text">四、写文章</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#五、技巧问题汇总"><span class="nav-text">五、技巧问题汇总</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#六、一些工具和教程地址"><span class="nav-text">六、一些工具和教程地址:</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2017</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">韦超</span>
</div>


<div class="powered-by">
  由 <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Mist
  </a>
</div>


        
<div class="busuanzi-count">
  <script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>

  
    <span class="site-uv">
      <i class="fa fa-user"></i>
      <span class="busuanzi-value" id="busuanzi_value_site_uv"></span>
      
    </span>
  

  
    <span class="site-pv">
      <i class="fa fa-eye"></i>
      <span class="busuanzi-value" id="busuanzi_value_site_pv"></span>
      
    </span>
  
</div>


        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.1"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.1"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.1"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.1"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.1"></script>



  


  




	





  





  





  






  

  <script type="text/javascript">
    // Popup Window;
    var isfetched = false;
    var isXml = true;
    // Search DB path;
    var search_path = "search.xml";
    if (search_path.length === 0) {
      search_path = "search.xml";
    } else if (search_path.endsWith("json")) {
      isXml = false;
    }
    var path = "/" + search_path;
    // monitor main search box;

    var onPopupClose = function (e) {
      $('.popup').hide();
      $('#local-search-input').val('');
      $('.search-result-list').remove();
      $('#no-result').remove();
      $(".local-search-pop-overlay").remove();
      $('body').css('overflow', '');
    }

    function proceedsearch() {
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay"></div>')
        .css('overflow', 'hidden');
      $('.search-popup-overlay').click(onPopupClose);
      $('.popup').toggle();
      var $localSearchInput = $('#local-search-input');
      $localSearchInput.attr("autocapitalize", "none");
      $localSearchInput.attr("autocorrect", "off");
      $localSearchInput.focus();
    }

    // search function;
    var searchFunc = function(path, search_id, content_id) {
      'use strict';

      // start loading animation
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay">' +
          '<div id="search-loading-icon">' +
          '<i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>' +
          '</div>' +
          '</div>')
        .css('overflow', 'hidden');
      $("#search-loading-icon").css('margin', '20% auto 0 auto').css('text-align', 'center');

      $.ajax({
        url: path,
        dataType: isXml ? "xml" : "json",
        async: true,
        success: function(res) {
          // get the contents from search data
          isfetched = true;
          $('.popup').detach().appendTo('.header-inner');
          var datas = isXml ? $("entry", res).map(function() {
            return {
              title: $("title", this).text(),
              content: $("content",this).text(),
              url: $("url" , this).text()
            };
          }).get() : res;
          var input = document.getElementById(search_id);
          var resultContent = document.getElementById(content_id);
          var inputEventFunction = function() {
            var searchText = input.value.trim().toLowerCase();
            var keywords = searchText.split(/[\s\-]+/);
            if (keywords.length > 1) {
              keywords.push(searchText);
            }
            var resultItems = [];
            if (searchText.length > 0) {
              // perform local searching
              datas.forEach(function(data) {
                var isMatch = false;
                var hitCount = 0;
                var searchTextCount = 0;
                var title = data.title.trim();
                var titleInLowerCase = title.toLowerCase();
                var content = data.content.trim().replace(/<[^>]+>/g,"");
                var contentInLowerCase = content.toLowerCase();
                var articleUrl = decodeURIComponent(data.url);
                var indexOfTitle = [];
                var indexOfContent = [];
                // only match articles with not empty titles
                if(title != '') {
                  keywords.forEach(function(keyword) {
                    function getIndexByWord(word, text, caseSensitive) {
                      var wordLen = word.length;
                      if (wordLen === 0) {
                        return [];
                      }
                      var startPosition = 0, position = [], index = [];
                      if (!caseSensitive) {
                        text = text.toLowerCase();
                        word = word.toLowerCase();
                      }
                      while ((position = text.indexOf(word, startPosition)) > -1) {
                        index.push({position: position, word: word});
                        startPosition = position + wordLen;
                      }
                      return index;
                    }

                    indexOfTitle = indexOfTitle.concat(getIndexByWord(keyword, titleInLowerCase, false));
                    indexOfContent = indexOfContent.concat(getIndexByWord(keyword, contentInLowerCase, false));
                  });
                  if (indexOfTitle.length > 0 || indexOfContent.length > 0) {
                    isMatch = true;
                    hitCount = indexOfTitle.length + indexOfContent.length;
                  }
                }

                // show search results

                if (isMatch) {
                  // sort index by position of keyword

                  [indexOfTitle, indexOfContent].forEach(function (index) {
                    index.sort(function (itemLeft, itemRight) {
                      if (itemRight.position !== itemLeft.position) {
                        return itemRight.position - itemLeft.position;
                      } else {
                        return itemLeft.word.length - itemRight.word.length;
                      }
                    });
                  });

                  // merge hits into slices

                  function mergeIntoSlice(text, start, end, index) {
                    var item = index[index.length - 1];
                    var position = item.position;
                    var word = item.word;
                    var hits = [];
                    var searchTextCountInSlice = 0;
                    while (position + word.length <= end && index.length != 0) {
                      if (word === searchText) {
                        searchTextCountInSlice++;
                      }
                      hits.push({position: position, length: word.length});
                      var wordEnd = position + word.length;

                      // move to next position of hit

                      index.pop();
                      while (index.length != 0) {
                        item = index[index.length - 1];
                        position = item.position;
                        word = item.word;
                        if (wordEnd > position) {
                          index.pop();
                        } else {
                          break;
                        }
                      }
                    }
                    searchTextCount += searchTextCountInSlice;
                    return {
                      hits: hits,
                      start: start,
                      end: end,
                      searchTextCount: searchTextCountInSlice
                    };
                  }

                  var slicesOfTitle = [];
                  if (indexOfTitle.length != 0) {
                    slicesOfTitle.push(mergeIntoSlice(title, 0, title.length, indexOfTitle));
                  }

                  var slicesOfContent = [];
                  while (indexOfContent.length != 0) {
                    var item = indexOfContent[indexOfContent.length - 1];
                    var position = item.position;
                    var word = item.word;
                    // cut out 100 characters
                    var start = position - 20;
                    var end = position + 80;
                    if(start < 0){
                      start = 0;
                    }
                    if (end < position + word.length) {
                      end = position + word.length;
                    }
                    if(end > content.length){
                      end = content.length;
                    }
                    slicesOfContent.push(mergeIntoSlice(content, start, end, indexOfContent));
                  }

                  // sort slices in content by search text's count and hits' count

                  slicesOfContent.sort(function (sliceLeft, sliceRight) {
                    if (sliceLeft.searchTextCount !== sliceRight.searchTextCount) {
                      return sliceRight.searchTextCount - sliceLeft.searchTextCount;
                    } else if (sliceLeft.hits.length !== sliceRight.hits.length) {
                      return sliceRight.hits.length - sliceLeft.hits.length;
                    } else {
                      return sliceLeft.start - sliceRight.start;
                    }
                  });

                  // select top N slices in content

                  var upperBound = parseInt('1');
                  if (upperBound >= 0) {
                    slicesOfContent = slicesOfContent.slice(0, upperBound);
                  }

                  // highlight title and content

                  function highlightKeyword(text, slice) {
                    var result = '';
                    var prevEnd = slice.start;
                    slice.hits.forEach(function (hit) {
                      result += text.substring(prevEnd, hit.position);
                      var end = hit.position + hit.length;
                      result += '<b class="search-keyword">' + text.substring(hit.position, end) + '</b>';
                      prevEnd = end;
                    });
                    result += text.substring(prevEnd, slice.end);
                    return result;
                  }

                  var resultItem = '';

                  if (slicesOfTitle.length != 0) {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + highlightKeyword(title, slicesOfTitle[0]) + "</a>";
                  } else {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + title + "</a>";
                  }

                  slicesOfContent.forEach(function (slice) {
                    resultItem += "<a href='" + articleUrl + "'>" +
                      "<p class=\"search-result\">" + highlightKeyword(content, slice) +
                      "...</p>" + "</a>";
                  });

                  resultItem += "</li>";
                  resultItems.push({
                    item: resultItem,
                    searchTextCount: searchTextCount,
                    hitCount: hitCount,
                    id: resultItems.length
                  });
                }
              })
            };
            if (keywords.length === 1 && keywords[0] === "") {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-search fa-5x" /></div>'
            } else if (resultItems.length === 0) {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-frown-o fa-5x" /></div>'
            } else {
              resultItems.sort(function (resultLeft, resultRight) {
                if (resultLeft.searchTextCount !== resultRight.searchTextCount) {
                  return resultRight.searchTextCount - resultLeft.searchTextCount;
                } else if (resultLeft.hitCount !== resultRight.hitCount) {
                  return resultRight.hitCount - resultLeft.hitCount;
                } else {
                  return resultRight.id - resultLeft.id;
                }
              });
              var searchResultList = '<ul class=\"search-result-list\">';
              resultItems.forEach(function (result) {
                searchResultList += result.item;
              })
              searchResultList += "</ul>";
              resultContent.innerHTML = searchResultList;
            }
          }

          if ('auto' === 'auto') {
            input.addEventListener('input', inputEventFunction);
          } else {
            $('.search-icon').click(inputEventFunction);
            input.addEventListener('keypress', function (event) {
              if (event.keyCode === 13) {
                inputEventFunction();
              }
            });
          }

          // remove loading animation
          $(".local-search-pop-overlay").remove();
          $('body').css('overflow', '');

          proceedsearch();
        }
      });
    }

    // handle and trigger popup window;
    $('.popup-trigger').click(function(e) {
      e.stopPropagation();
      if (isfetched === false) {
        searchFunc(path, 'local-search-input', 'local-search-result');
      } else {
        proceedsearch();
      };
    });

    $('.popup-btn-close').click(onPopupClose);
    $('.popup').click(function(e){
      e.stopPropagation();
    });
    $(document).on('keyup', function (event) {
      var shouldDismissSearchPopup = event.which === 27 &&
        $('.search-popup').is(':visible');
      if (shouldDismissSearchPopup) {
        onPopupClose();
      }
    });
  </script>





  

  

  

  

  

</body>
</html>
